import React, { Component, PureComponent } from 'react'

class LoginPage extends Component {
  render() {
    return (
      <div>
        Login
      </div>
    )
  }
}

// 权限
function withAuth(WrappedComponent) {
  const NewCpn = props => {
    const { isLogin } = props
    if(isLogin) {
      return <WrappedComponent {...props} />
    } else {
      return <LoginPage />
    }
  }

  NewCpn.displayName = "AuthCpn"
  return NewCpn
}

// 购物车组件
class CartPage extends PureComponent {
  render() {
    return <h2>CartPage</h2>
  }
}

export default class App extends Component {
  render() {
    return (
      <div>
        <CartPage isLogin={true}/>
      </div>
    )
  }
}
